<?php

namespace app\index\controller;

use coser\Controller;
use app\index\model\MediaModel;
use app\index\model\ClockModel;

class Index extends Controller
{

    public function index()
    {
        $mediaModel = new MediaModel();
        $mediaList = $mediaModel->getList(['pid'=>1]);

        $clockModel = new ClockModel();
        $clockList = $clockModel->getList(['uid'=>1,'start_time'=>['>',time()]]);
        foreach ($clockList as $key => $val){
            $clockList[$key]['rema'] = $val['start_time'] - time();
            $clockList[$key]['time'] = date('H:i',$val['start_time']);
        }

        $this->assign('hi',':)');
        $this->assign('mediaList',$mediaList);
        $this->assign('clockList',$clockList);
        $this->display('index');
    }


    public function clock()
    {
		$mediaModel = new MediaModel();
        $mediaList = $mediaModel->getList(['pid'=>1]);

        $clockModel = new ClockModel();
        $clockList = $clockModel->getList(['uid'=>1,'start_time'=>['>',time()]]);
		foreach ($clockList as $key => $val){
            $clockList[$key]['rema'] = $val['start_time'] - time();
            $clockList[$key]['time'] = date('H:i',$val['start_time']);
        }

		$this->assign('hi',':)');
		$this->assign('mediaList',$mediaList);
        $this->assign('clockList',$clockList);
		$this->display('clock');
    }
	
	public function addMenu()
	{
		$data = [
			'item'	=>	'"时钟"',
			'top'	=>	'1',
			'pid'	=>  '1',
			'create_time'	=>	time(),
			'update_time'	=>	time(),
		];
		
		$menuModel = new MenuModel();
		$menuModel->add($data);
	}

	public function menuList()
	{
		$where = [
			't1.id' => 1
		];
		
		$menuModel = new MenuModel();
		$menuModel->getlist($where);
	}

}